﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Mclib
{
	/// <summary>
	/// A class that represents a standard data series with 2D [x,y] coordinates.
	/// This class can be used to draw line plots and other related plots.
	/// </summary>
	public class DataSeries
	{
		/// <summary>
		/// The data series.
		/// </summary>
		public PointF[] Series;
		/// <summary>
		/// The pen used for drawing the axis, width is automatically scaled by DrawScale.
		/// </summary>
		public Pen Pen
		{
			get { return pen; }
			set
			{
				pen = value;
				scaledPen = new Pen(pen.Color,pen.Width*drawScale);
			}
		}
		private Pen pen = new Pen(Color.Black,1.0f);
		private Pen scaledPen = new Pen(Color.Black,1.0f);
		/// <summary>
		/// The scale with which to draw the axis.  Automatically scales the font and the pen.
		/// </summary>
		public float DrawScale
		{
			get { return drawScale; }
			set
			{
				if (value!=drawScale)
				{
					drawScale = value;
					scaledPen = new Pen(pen.Color,pen.Width*drawScale);
				}
			}
		}
		private float drawScale = 1.0f;
		/// <summary>
		/// Construct a new instance from a specified series of (x,y) coordinates.
		/// </summary>
		/// <param name="x">The x-coordinates.  Must be the same length as y.</param>
		/// <param name="y">The y-coordinates.  Must be the same length as x.</param>
		public DataSeries(double[] x,double[] y)
		{
			if (x.Length!=y.Length)
				throw new ArgumentException("Arguments x and y must be vectors of the same length.");
			Series = new PointF[x.Length];
			for (int i=0; i<x.Length; i++)
				Series[i] = new PointF((float)x[i],(float)y[i]);
		}
	}
}